package com.cy.jt.portals.controller;

import com.cy.jt.common.domain.SysNotice;
import com.cy.jt.common.vo.JsonResult;
import com.cy.jt.portals.service.feign.RemoteNoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/portals/")
public class PortalsController {
    @Autowired
    private RemoteNoticeService remoteNoticeService;
    /*
    报错信息：
        feign.FeignException$MethodNotAllowed: [405] during [GET] to [http://
        jt-system/notice/select] [RemoteNoticeService#doSelectNotice(SysNotice)
        ]: [{"timestamp":"2021-09-06T02:59:44.094+00:00","status":405,"error":
        "Method Not Allowed","message":"","path":"/notice/select"}]
    问题：OpenFeign新版本将get请求改为post请求
    解决办法：
    解决办法一：
    如下：把get请求改为post请求
    @PostMapping ("notice")
    public JsonResult doSelectNotice(@RequestBody SysNotice notice){
        //如何调用notice服务呢？
        return remoteNoticeService.doSelectNotice(notice);
    }
     */
    /*
    解决办法二：
        如下：就用get请求，不用新版的OpenFeign
        操作如下：
        在依赖中添加如下依赖：
        <dependency>
            <groupId>io.github.openfeign</groupId>
            <artifactId>feign-httpclient</artifactId>
            <version>10.9</version>
        </dependency>
        在yml文件中添加如下配置：
        feign:
          httpclient:
            enabled: true
     */
    //请求路径：http://localhost:9081/portals/notice/?pageCurrent=2&pageSize=1
    @GetMapping ("notice/")
    public JsonResult doSelectNotice(/*@RequestBody*/ SysNotice notice){
        //如何调用notice服务呢？
        return remoteNoticeService.doSelectNotice(notice);
    }
}
